/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.etop.odbs.dao;

import com.etop.odbs.beans.Collection;
import java.util.List;

/**
 *
 * @author JayceKong
 */
public class CollectionDao extends BaseDao {
    //添加一个收藏的对象
    public void add(Collection c){
        this.getSession().save(c);
        this.getSession().beginTransaction().commit();
        this.getSession().close();
    }
    
    public List load(int id){
        String hql="select col from collection col where uid=?";
        List<Collection> collections=this.getSession().createQuery(hql).setParameter(0, id).list();
        return collections;
    }
    
    public void delete(int u_id,int d_id){
       String hql="select col from collection col where u_id=? and d_id=?";
       Collection collection=(Collection)this.getSession().createQuery(hql).setParameter(0, u_id).setParameter(1, d_id).uniqueResult();
       this.getSession().delete(collection);
       this.getSession().beginTransaction().commit();
    }
}
